package cn.distribution.groupManager.service;

import cn.distribution.groupManager.entity.dao.GroupManagerDAO;
import cn.distribution.groupManager.entity.vo.GroupManagerVO;
import cn.distribution.groupManager.mapper.GroupManagerMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 群组服务类
 * @author zhengminjie
 */
@Service
public class GroupManagerService extends ServiceImpl<GroupManagerMapper, GroupManagerDAO> {

    @Resource
    private GroupManagerMapper groupManagerMapper;

    /**
     * 通过群号得到群id
     */
    public Long getIdByNum(Long groupNum){
        return groupManagerMapper.getIdByNum(groupNum);
    }

    /**
     * @author xiayujia
     * 通过用户身份,id得到群名
     * */
    public List<GroupManagerDAO> getGroupNameByIdentity(String userIdentity,Long userId){
        return this.groupManagerMapper.getGroupNameByIdentity(userIdentity,userId);
    }

    /**
     * 通过群号得到群昵称
     */
    public String getNameByNum(Long groupNum) {
        return groupManagerMapper.getNameByNum(groupNum);
    }

    /**
     * @author xiayujia
     * 通过群id得到群昵称
     */
    public String getNameById(Long groupId) {
        return groupManagerMapper.getNameById(groupId);
    }

    /**
     * 通过群号或者群昵称得到列表
     */
    public List<GroupManagerDAO> getGroupAll(Long userId,Long groupNum,String groupName){
        return groupManagerMapper.getGroupAll(userId, groupNum, groupName);
    }

    /**
     * 通过群号或者群昵称得到自己群的列表
     */
    public List<GroupManagerVO> getGroup(Long userId,Long groupNum,String groupName){
        return groupManagerMapper.getGroup(userId, groupNum, groupName);
    }
}
